home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-12-04 | 35.6 KB | 691 lines | [TEXT/MPS ] |
- /************** AEConnect.c **************/
-
- void InitConnectAppleEvents(void);
- /* This function initializes the connect AppleEvents stuff. It needs to be
- ** called so that MacShell applications can connect with other applications
- ** specific to a targeted window. */
-
- pascal OSErr DoAEAnswer(AppleEvent *message, AppleEvent *reply, long refcon);
- /* This function handles the connect reply. MacShell sends the connect request
- ** via kAEQueueReply. This means that it doesn't necessarily come back immediately.
- ** (It actually comes back right away if it is connected to itself.) The reply
- ** normally comes in via a high-level event. Until this reply comes in, the
- ** connection isn't established. When this reply does come in, the remaining
- ** information necessary to establish the connection to a particular window in
- ** the target application is recorded. */
-
- OSErr SendConnect(FileRecHndl frHndl);
- /* This is the function that is called to establish a connection to another MacShell-based
- ** application. The "other" MacShell application is probably the same application on
- ** another machine. This code does a bit more than simply connecting to another
- ** application. It targets a specific window within that application. It doesn't just
- ** target zone/machine/application, which is the granularity that AppleEvents gives you.
- ** It also passes back and forth some information that is kind of a pain to get, but
- ** is nice to have. One such piece of information is the user name. This needs to be
- ** sent. It can't be determined from the message from an AppleEvent. The sender sends
- ** the user name, and the receiver returns the remote user name. The user name is
- ** placed in the document record for the window to be used if you wish. */
-
- pascal OSErr ReceiveConnect(AppleEvent *message, AppleEvent *reply, long refcon);
- /* This function receives a connect message from SendConnect. The connection
- ** tasks that the receiver has to do are done here, such as opening a window for
- ** this end of the connection, etc. It also returns whether or not it succeeded,
- ** and the user name. Basically, it establishes the connection, while keeping
- ** some data as to whom it is connected to. */
-
- pascal OSErr ReceiveConnectReply(AppleEvent *message, AppleEvent *reply);
- /* This function is called when you want to determine which window an AppleEvent
- ** is targeted for. MacShell AppleEvents send two long values along with the AppleEvent
- ** to determine which window is the target window. One of the longs is an ID for the
- ** sender, and the other is an ID for the receiver. When a connection is established,
- ** these values are saved for both the sender and the receiver. This allows the
- ** AppleEvent to be sent in either direction and still be targeted to the correct window.
- ** To find which window is the target, get these two longs out of the AppleEvent and then
- ** call GetAEWindow. The first value is always the ID of the machine itself, and the
- ** second value is always the ID of the remote machine. Due to this, you will need to
- ** reverse the order of these ID's for incomming MacShell AppleEvents. */
-
- WindowPtr GetAEWindow(long windID_0, long windID_1);
- /* This function is called to determine which window, if any, is the designated
- ** target window. The window ID's are determined when the connection is established. */
-
- pascal Boolean AEPortFilter(LocationNamePtr locationName, PortInfoPtr thePortInfo);
- /* This function doesn't allow the PPCBrowser to display any applications other
- ** than the designated application(s). */
-
-
-
- /************** AECustom.c **************/
-
- void InitCustomAppleEvents(void);
- /* This function initializes the custom AppleEvents stuff. Any custom AppleEvents
- ** you create should be added to the AppleEvents dispatch table here. */
-
- OSErr SendMessage(FileRecHndl frHndl, short messageType);
- /* A lot of times the data that you want to send is just a hunk of data. You really
- ** aren't all that concerned about any particular format. If you are both the sender
- ** and receiver, then you know what is going on, and sometimes this is just fine.
- ** Of course, this means that you won't be communicating this data with other
- ** applications in any meaningful sort of way. If this private quick-and-dirty data
- ** sending is what you want, then SendMessage will do it for you.
- ** In Kibitz, I had two kinds of data that were less than 32k. I had sound data, and
- ** I had TextEdit text. Both of these data types were just a bunch of bytes.
- ** SendMessage allows you to assign a data type, and then the block of data.
- ** It is a convenient way to send smaller, private blocks of data. The data will be
- ** received by the function ReceiveMessage. */
-
- pascal OSErr ReceiveMessage(AppleEvent *message, AppleEvent *reply, long refcon);
- /* This function is where you get the data sent by SendMessage. The kind of data
- ** is determined by an assigned message type. Based on this value, you will
- ** interpret the data in varying ways, depending on the needs of your application. */
-
-
-
- /************** AERequired.c **************/
-
- void InitRequiredAppleEvents(void);
- /* Intializes AppleEvent dispatcher table for the required events. It also
- ** determines if the machine is PPCBrowser and AppleEvent capable. If so,
- ** the booleans gHasAppleEvents and gHasPPCToolbox are set true. This function
- ** must be the first AppleEvents initialization MacShell function called, as the
- ** other functions depend on the booleans being set correctly. */
-
- pascal OSErr DoAEOpenApplication(AppleEvent *message, AppleEvent *reply, long refcon);
- /* This function opens a new MacShell document due to an AppleEvents request. */
-
- pascal OSErr DoAEOpenDocuments(AppleEvent *message, AppleEvent *reply, long refcon);
- /* This function opens existing MacShell documents due to an AppleEvents request. */
-
- pascal OSErr DoAEPrintDocuments(AppleEvent *message, AppleEvent *reply, long refcon);
- /* This function prints MacShell documents due to an AppleEvents request. */
-
- pascal OSErr DoAEQuitApplication(AppleEvent *message, AppleEvent *reply, long refcon);
- /* This function sets a quit flag so that MacShell will quit due to an AppleEvents request. */
-
- OSErr OpenDocEventHandler(AppleEvent *message, AppleEvent *reply, short mode);
- /* This is the function that actually does the document opening for AppleEvents. */
-
-
-
- /************** AEUtils.c **************/
-
- void DoHighLevelEvent(EventRecord *event);
- /* This function simply calls AEProcessAppleEvent and reports any errors. */
-
- OSErr GetTargetInfo(AEAddressDesc targetDesc, StringPtr zone, StringPtr machine, StringPtr application);
- /* This function returns the zone, machine, and application name for the
- ** indicated target descriptor. */
-
- OSErr MakeTarget(AEAddressDesc *target, Boolean sendDirect, short replyMode, Str255 prompt, Str255 applListLabel, PPCFilterProcPtr portFilter, char *theLocNBPType);
- /* Creates a TargetID. If sendDirect is TRUE, the target is specified by setting
- ** a ProcessSerialNumber to kCurrentProcess. This has the advantage of sending
- ** the message directly to ourselves, bypassing ePPC and gaining about a 10-15x
- ** speed improvement. If sendDirect is FALSE, we see if we have the
- ** PPCToolBox. If not, then we are forced to do a direct send. If we do have
- ** the PPCToolbox, then we call PPCBrowser. We then look at the reply, and
- ** factor in the mode we are going to use in AESend. If that mode is
- ** kAEWaitReply and the user selected us as the target, we have to turn that
- ** into a direct send. This is because the AppleEvent Manager will otherwise
- ** post the event as a high-level event. However, we are busy waiting for a
- ** reply, not looking for events, so we'll hang. We avoid this by forcing a
- ** direct send. */
-
- Boolean MissedAnyParameters(AppleEvent *message);
- /* Used to check for any unread required parameters. Returns true if we
- ** missed at least one. */
-
-
-
- /************** AppleTalk.c **************/
-
- OSErr ATInit(void);
- /* Currently does nothing. Calling it allows the AppleTalk.c.o file to be needed
- ** by the link. */
-
- OSErr DoBuildZoneList(ListHandle listHndl);
- /* Given a list record, this function places all of the zone names in
- ** the list. Prior to calling this function, you need to create a
- ** list record that has zero rows and one column. The zones are added
- ** to the list in the column in alphabetical order. The function
- ** IUMagString is used to determine order. */
-
- OSErr DoSelectMyZone(ListHandle listHndl);
- /* Given a list of zones (probably generated by DoBuildZoneList), this
- ** function selects the zone the user is currently in. The current zone
- ** is selected and scrolled into view. */
-
- OSErr AddPPCNBPAlias(NamesTableEntry *theNTE, Str32 newNBPType, EntityName *newEntity);
- /* This function regsters an alias for the application. This allows PPCBrowser
- ** to be used to display only machines registered with that alias, instead of
- ** all machines that are PPCToolbox capable. This function is called by
- ** MacShell at startup time, as the alias only needs to be registered once. If
- ** there is more than one version of the application running on a single
- ** machine, AddPPCNBPAlias will append a number to the application name.
- ** This allows each copy of the application to be displayed by PPCBrowser. */
-
- OSErr RemoveNBPAlias(EntityPtr theEntity);
- /* This function removes the designated alias. This is executed by MacShell at
- ** application quit time. */
-
-
- /************** DoCursor.c **************/
-
- void DoCursor(void);
- /* The cursor management code for your application belongs here. Your job is
- ** to update the cursor region and also to set the correct cursor for that
- ** region. The region gCurrentCursorRgn will be used for the WaitNextEvent call.
- ** This global region should be updated by DoCursor. */
-
- void DoSetCursor(Cursor *cursor);
- /* DoCursor is normally used to set the cursor. DoCursor also sets the cursor
- ** region for the WaitNextEvent call. DoSetCursor is for when you need a temporary
- ** cursor for a dialog or alert, or whatever. You can call DoSetCursor to set this
- ** temporary cursor. By calling DoSetCursor, you make sure that when you return to
- ** the main event loop, the cursor will be recalculated, even if it is still over
- ** the old cursor region. You don't have to call DoSetCursor to cause the cursor
- ** and cursor region for WaitNextEvent to be recalculated. You could also simply
- ** set gCursorPtr to nil. */
-
-
-
- /************** DoEvent.c **************/
-
- void DoEvent(EventRecord *event);
- /* You definitely want to modify this function. This is the main dispatcher for
- ** the application event loop. Change the code for the different cases as is
- ** appropriate for your application. */
-
- void DoActivate(WindowPtr window, Boolean becomingActive);
- /* This function activates or deactivates the window, as appropriate. It changes
- ** the state of the window controls and grow icon. If there is anything else
- ** that needs to be done for your application's windows during activation or
- ** deactivation, then it needs to be done here. */
-
- void DoUpdate(WindowPtr window);
- /* This function is called to update the window contents. It does this in two
- ** stages. It first updates the document scrollbars (if any) and growIcon (if
- ** there is one). It then sets up for updating the rest of the window content.
- ** This setup consists of removing the document scrollbar and growIcon area
- ** from the visRgn. The area is removed from the visRgn so that the clipRgn
- ** can be used by the application for clipping.
- ** To update the document scrollbar and growIcon area, the function
- ** DoDrawScrollGrow is called. To update the remainder of the content area,
- ** the procedure pointed to by the window's document field imageProc is called. */
-
- /************** EventLoop.c **************/
-
- void EventLoop(void);
- /* This is the main application event loop. It simply calls WaitNextEvent
- ** and DoEvent until the user decides to quit. */
-
-
-
- /************** File.c **************/
-
- OSErr AppDisposeDocument(FileRecHndl frHndl);
- /* This function is automatically called by MacShell at appropriate times. It
- ** calls AppFreeDocument, which is application specific. See AppFreeDocument
- ** for more information. */
-
- OSErr AppNewDocument(FileRecHndl *returnHndl, OSType sftype);
- /* This function is automatically called by MacShell at appropriate times. It
- ** calls AppInitDocument, which is application specific. See AppInitDocument
- ** for more information. */
-
- OSErr AppOpenDocument(FileRecHndl *result, FSSpecPtr fileToOpen, char permission);
- /* This function does the human-interface thing for opening a document. It
- ** also calls AppNewDocument to initialize a document. To actually read in
- ** the data, AppOpenDocument calls AppReadDocument, which is application
- ** specific. See AppReadDocument for more information. */
-
- OSErr AppSaveDocument(FileRecHndl frHndl, WindowPtr window, short saveMode);
- /* This function does the human-interface thing for saving a document. To
- ** actually write out the data, AppSaveDocument calls AppWriteDocument, which
- ** is application specific. See AppWriteDocument for more information. */
-
- void ConvertOldToNewSFReply(SFReply *oldReply, StandardFileReply *newReply);
- /* When running on a pre-7.0 system, SFGetFile or SFPutFile is called. Then
- ** ConvertOldToNewSFReply is called to convert the reply record to the new
- ** format. This allows the rest of the application to use only a single
- ** record format. */
-
- OSErr Create_OpenFile(FSSpec *file, short *refNum);
- ** Opens the file specified by the passed FSSpec, creating it if it doesn't
- ** already exist. Refturns the refnum of the open file to the application.
- ** File Manager errors are reported and returned. */
-
- Boolean DisplayGetFile(StandardFileReply *reply);
- /* Simple routine to display a list of files with our file type. */
-
- Boolean DisplayPutFile(StandardFileReply *reply);
- /* Displays the StandardFile PutFile dialog box. Fills out the passed reply
- ** record, and returns the sfGood field as a result. */
-
- void IncNewFileNum(Boolean flag);
- /* This function sets a boolean that indicates whether or not the new file
- ** number should be incremented. New files are opened with a default title.
- ** The title states that the document is untitled, and gives it a number.
- ** Sometimes you will want to open a file and not use a new untitled number.
- ** This would be for reasons of printing, or for a temporary work file.
- ** In these cases, you would first call IncNewFileNum with false. You would
- ** then do the operations on the temporary file. Once these operations are
- ** complete, you would then call IncNewFileNum with true to reenable untitled
- ** title incrementing. */
-
-
-
- /************** File2.c **************/
-
- void AppFreeDocument(FileRecHndl frHndl);
- /* This function is where you do the application specific document disposal
- ** things. This function is called by AppDisposeDocument at appropriate
- ** times by MacShell. */
-
- OSErr AppInitDocument(FileRecHndl frHndl);
- /* This function is where you do the application specific document
- ** initialization things. This function is automatically called at
- ** appropriate times by MacShell. */
-
- OSErr AppReadDocument(FileRecHndl frHndl);
- /* This function is where the document data is read in. This function is
- ** automatically called at appropriate times by MacShell. Your application
- ** may not necessarily read in all of the data. Your file may be disk-based.
- ** It is completely up to you. Of course, if your document is disk-based,
- ** other parts of your application will need to know this and read in the
- ** data as needed. (You can now do this by using VM. Just read the document
- ** in as if you have lots of memory.) This function also reads in the
- ** print record and file version number. MacShell depends on there being
- ** a print record read in from the file. The reason that this is not
- ** automatically done for you at a higher level is that this would place
- ** a restriction on the file format. You may have the print record stored
- ** elsewhere, or your file may not have one saved. In either case, you do
- ** need to read or produce one for the rest of MacShell to be happy. Given that
- ** there is no restriction on the file format, you can use existing file
- ** formats within MacShell. This allows your application to read other file
- ** formats from other applications. */
-
- OSErr AppWriteDocument(FileRecHndl frHndl);
- /* This function is where the document data is written out. This function is
- ** automatically called at appropriate times by MacShell. Your application
- ** may not necessarily write all of the data. (See AppReadDocument.) */
-
- OSErr AppDuplicateDocument(FileRecHndl oldFrHndl, FileRecHndl *newFrHndl);
- /* This function is use to duplicate a document. Your application may not
- ** have this feature. If not, then yank the associated menu item and code, and
- ** this function as well. */
-
-
-
- /************** Help.c **************/
-
- void DynamicBalloonHelp(void);
- /* This function is used to do balloon help for the content of a window. */
-
-
-
- /************** IdleTasks.c **************/
-
- void DoIdleTasks(EventRecord *event);
- /* If your application has an tasks that need to be done at idle time, this
- ** is the place to put them. It is automatically called at appropriate times
- ** by MacShell. */
-
- void NotifyCancel(void);
- void NotifyUser(void);
- /* These two functions are the routines used to use the Notification Manager.
- ** NotifyUser is called by MacShell when an AppleEvent comes in to MacShell and
- ** MacShell isn't the front application. NotifyCancel is called by MacShell when
- ** the user brings it to the front. */
-
-
-
- /************** Init.c **************/
-
- void Initialize(void);
- void StartDocuments(void);
- /* These functions are startup code that shouldn't have to change. */
-
-
-
- /************** Menu.c **************/
-
- void AdjustMenus(void);
- /* This function is where your application would make menu changes, such as
- ** enabling or disabling menu choices, adding or removing menu items, etc. */
-
- void EnableOrDisableItem(MenuHandle menu, short item, Boolean enable);
- /* This function simply calle EnableItem or DisableItem, depending on the
- ** boolean value passed it. */
-
- void DoMenuCommand(long menuResult);
- /* This function is where your application would respond to menu commands. */
-
-
-
- /************** Print.c **************/
-
- OSErr AppPrintDocument(FileRecHndl frHndl, Boolean jobDlg, Boolean firstJob);
- OSErr PresentStyleDialog(FileRecHndl frHndl);
- /* These two functions are the generic print support for MacShell. You shouldn't
- ** have to make any changes to these functions. AppPrintDocument calls the
- ** designated image procedure. The default procedure is ImageDocument. You can
- ** change it if you wish. ImageDocument images the document to either the window
- ** or to the printer. The port is already set when ImageDocument is called to either
- ** the window's port or the printer port. The global variable gPrintPage is set
- ** so that you can determine if you are imaging for the window or for the printer.
- ** If gPrintPage is 0 then you are imaging for the window. If gPrintPage is non-0,
- ** then that is the page you are imaging to the printer. If you are printing, and
- ** have imaged the final page, your imaging code should set gPrintPage to 0. This
- ** tells AppPrintDocument that you have done the final page. The reason for this
- ** is that the user could request to print pages 4 to 27, and you only have 14 pages
- ** in the document. The imaging procedure "knows" how many pages the document
- ** has, and by having the imaging procedure return that it is finished, we eliminate
- ** the need for the generic print code to have to know how many pages are in the
- ** document. */
-
-
-
- /************** Start.c **************/
-
- void main(void);
- /* This is where the MacShell application gets called first (obviously).
-
-
-
- /************** Utils.c **************/
-
- void appendi2cstr(char *cstr, short i);
- short appendi2pstr(char *pstr, short i);
- short i2cstr(char *cstr, short i);
- void i2pstr(char *pstr, short i);
- void pstrcat(char *d, char *s);
- void pstrcpy(char *d, char *s);
- short GetHexByte(char *cptr);
- /* These functions are a collection of useful things for C programmers. */
-
- pascal Boolean alertFilter(DialogPtr dlg, EventRecord *event, short *item);
- /* The alert filter makes sure that that the outline for the button gets
- ** redrawn. This is important if balloon help is on, as the balloon window
- ** can overlap the outline of the button and leave a portion of it erased. */
-
- pascal Boolean keyEquivFilter(DialogPtr dlg, EventRecord *event, short *item);
- /* The key equivalent filter allows you to assign key equivalents to dialog
- ** items. Each item can have as many key equivalents as you wish. You can
- ** also specify the exact state of the modifiers that you will or won't allow.
- ** The key equivalent information is stored in the resource fork, so the
- ** key equivalents can be easily localized.
- ** This code expects the key equivalents to be in item #2, which is a StatText
- ** item that is located so the text is outside of the dialog. This allows us
- ** to put key equivalent information in the resource fork, so the key
- ** equivalents are localizable.
- **
- ** An example save changes before closing or quitting res source with
- ** keyEquiv info would look like:
- **
- ** resource 'DITL' (rYesNoCancel, purgeable) {
- ** {
- ** {71, 315, 91, 367}, Button { enabled, "Save" },
- ** {0, -1000, 20, 2}, StaticText { disabled,
- ** "=S190001,=s190001,=D190003,=d190003,=.190104,1B190004" },
- ** {71, 80, 91, 162}, Button { enabled, "Don’t Save" },
- ** {71, 244, 91, 302}, Button { enabled, "Cancel" },
- ** {11, 78, 61, 366}, StaticText { disabled,
- ** "Save changes to the document “^0” before ^1?" },
- ** {11, 23, 43, 55}, Icon { disabled, 2 }
- ** }
- ** };
- **
- ** The document name would be the string for param #0.
- ** The text "closing" or "quitting" would be the string for param #1.
- **
- ** The keyEquiv entry is item #2, which has a rect that pushes it out of the
- ** dialog. The string info is interpreted as to what the key/modifier combo
- ** is, and what dialog item it relates to.
- **
- ** A single key equiv entry is 8 characters. Entries are separated by commas.
- **
- ** If the first character of an entry is an =, then the next character is the
- ** key. If the first character isn't an =, then the first two characters are
- ** the hex value of the key. (Ex: =S or =s for save, 1B for ESC.)
- **
- ** If the key pressed is the same as the key value for any of the entries, then
- ** the next two characters are the hex value for which modifiers to test. This
- ** modifier test value is anded with the modifier. The result is then compared
- ** to the value of the next two hex digits. If they are equal, then the
- ** modifiers are correct, as well as the key. If this is so, we have a winner.
- **
- ** "=S190001,=s190001,=D190003,=d190003,=.190104,1B190004"
- **
- ** The above string breaks down as follows:
- ** =S190001 =S if event keypress is an S, check the modifier values
- ** 19 check controlKey/optionKey/cmdKey
- ** 00 all modifiers we are testing for should be false
- ** 01 if above is true, keypress maps to item # 1
- ** =s190001 Same as =S, but lowercase
- ** =D190001 Same as =S, but maps to item #3
- ** =d190001 Same as =D, but lowercase
- ** =.190104 =. if event keypress is a period, check the modifier values
- ** 19 check controlKey/optionKey/cmdKey
- ** 01 controlKey/optionKey should be false, cmdKey should be true
- ** 04 if above is true, keypress maps to item # 4
- ** 1B190004 1B if event keypress is an ESC, check the modifier values
- ** 19 check controlKey/optionKey/cmdKey
- ** 00 all modifiers we are testing for should be false
- ** 04 if above is true, keypress maps to item # 4
- */
-
- void OffsetControl(ControlHandle ctl, short dx, short dy);
- /* This function is a convenient way to move a control a specified amount. */
-
- void DoDrawGrowIcon(WindowPtr window, Boolean horLine, Boolean verLine);
- /* This function draws the grow icon for the window in the specified manner. You
- ** can clip out the horizontal or vertical line that is also drawn along with
- ** the grow icon, or you can have them draw. */
-
- void DoDrawControls(WindowPtr window, Boolean scrollBarsOnly);
- /* This function drawn all of the controls in a window, or just the scrollbar
- ** controls. The reason for this function is that scrollbars are really
- ** tri-state, especially now with 7.0. A scrollbar can be hilighted or not,
- ** or it can be drawn in a window that isn't the frontmost of the application
- ** plane. DoDrawControls takes this third scrollbar state into consideration. */
-
- void DoDraw1Control(ControlHandle ctl, Boolean scrollBarsOnly);
- /* This function is where the work for scrollbar/control drawing is actually
- ** done. DoDrawControls calls this function for each control in a window. */
-
-
-
- /************** Window.c **************/
-
- OSErr DoNewWindow(FileRecHndl frHndl, WindowPtr *retWindow, WindowPtr behind, short attributes);
- /* This function is called by MacShell at appropriate times to give a document
- ** a window. To create a document window, first a document is created via
- ** AppNewDocument or AppOpenDocument. If this succeeds then MacShell will give
- ** the document a window. To do this, MacShell calls DoNewWindow. DoNewWindow
- ** calls the content initialization procedure, which by default is InitContent.
- ** If you want a different content initialization procedure, replace the
- ** default procedure pointer initContentProc with our own. Normally however,
- ** you will just place your own content initialization procedure in the
- ** function InitContent. It is possible though that your
- ** application has more than one document type and window type. If this
- ** is the case, then you may very well want an alternate content
- ** initialization procedure. If you do, you will want to replace the
- ** default procedure pointer after the AppNewDocument or AppOpenDocument
- ** call and before the call to DoNewWindow. (You may place the code for
- ** replacing the content initialization procedure and imaging procedure
- ** in the function AppInitDocument. The defaults are already extablished
- ** at that point. You would just replace them with the alternates. */
-
- void NewWindowTitle(WindowPtr window);
- /* Call this function if you want to change the title of the window. */
-
- Boolean GetWindowDirty(WindowPtr window);
- /* This function returns a boolean as to if the document for a window
- ** has been changed. */
-
- void SetWindowDirty(WindowPtr window);
- /* This function flags the document that owns the window as dirty. */
-
- Boolean DisposeAllWindows(void);
- Boolean DisposeOneWindow(WindowPtr window, short saveMode);
- /* These functions do exactly as you would expect. The saveMode indicates
- ** whether the window is being closed due to a close request, or due to the
- ** application being quit. */
-
- WindowPtr SetFilePort(FileRecHndl frHndl);
- /* This function sets the current port for the designated file. It also returns
- ** the old port so that the port can be restored, if so desired. */
-
- void DoResizeWindow(WindowPtr window, short oldh, short oldv);
- /* This function is called when a window is resized. This function needs to
- ** know the old size of the window. The new size is determined by the
- ** dimensions of the window that was resized. It moves and resizes the
- ** document scrollbars and growIcon (if any) to reflect the new size of
- ** the window. It then calls the procedure stored in the procPtr field
- ** resizeContentProc, in case there is additional sizing necessary for the window.
- ** The default resizeContentProc is ResizeContent. If you wish an alternate
- ** resizeContentProc, then you can replace the default in the function
- ** AppInitDocument, as the default is already established at this point. */
-
- void DoDrawFrame(WindowPtr window);
- /* This function may be called when an update event occurs for the window.
- ** If the update region intersects the frame region (calculated by DoCalcFrameRgn),
- ** then a frame update occurs and this function is called. It redraws the
- ** document scrollbars and growIcon (if any) and then calls the procedure stored
- ** in the field drawFrameProc, which has a default value of DrawFrame. If you wish
- ** an alternate drawFrameProc, then you can replace the default in the function
- ** AppInitDocument, as the default is already established at this point. */
-
- RgnHandle DoCalcFrameRgn(WindowPtr window);
- /* This function calculates the region that encompasses the document scrollbars
- ** and growIcon (if any). The region is generated in global coordinates. Since
- ** the frame region may encompass more than the MacShell-supported scrollbars and
- ** growIcon, a procedure is first called to see if there is anything additional
- ** in the frame region. The field calcFrameRgnProc holds the procedure pointer
- ** that contributes any extra to the frame region. This function is passed an
- ** empty region. If there is no additional contribution to the frame region,
- ** then the region should be left empty. Once this procedure is returned from,
- ** the remaining frame portion is added to this region. The remaining portion
- ** would consist of MacShell document scrollbars and a growIcon, if there
- ** are any for this window. The field calcFrameRgnProc is initialized to the
- ** default value CalcFrameRgn. If you wish an alternate drawFrameProc, then you
- ** can replace the default in the function AppInitDocument, as the default is
- ** already established at this point. */
-
- void DoUpdateSeparate(WindowPtr window, RgnHandle *contRgn, RgnHandle *frameRgn);
- /* This function separates the update region into two portions. One portion
- ** is the area that needs updating for the document scrollbars and growIcon
- ** (if any). The other portion is the rest of the window content that needs
- ** updating. This separation is so that the document scrollbars can be updated
- ** first, and then this area can be clipped out of the rest of the updating so
- ** that the window content doesn't draw over the document scrollbars and growIcon.
- ** The clipping is managed with just the visRgn. This frees up the clipRgn for
- ** application specific clipping. */
-
- void BeginContent(WindowPtr window);
- /* This function clips out the document scrollbars and growIcon from the
- ** updatable area. It also sets the origin of the port to the current
- ** document scrollbar values. BeginContent must be balanced by a call
- ** to EndContent. Calls to BeginContent and EndContent can not be
- ** nested. BeginContent clips out the document scrollbar and growIcon area
- ** without involving the clipRgn so that the application is free to use the
- ** clipRgn as it sees fit. The only caveat is that you can not modify the
- ** updateRgn between the BeginContent and EndContent calls, as anything
- ** contributed to the updateRgn between these calls will be lost. If you
- ** need to do this, accumulate the areas in a separate region, call
- ** EndContent, and then call InvalRgn. */
-
- void EndContent(WindowPtr window);
- /* Calls to BeginContent must be balanced. They also can't be nested.
- ** EndContent undoes the clipping of the document scrollbars and growIcon
- ** that BeginContent invoked. */
-
- void AdjustScrollBars(WindowPtr window);
- /* You call this function whenever you change the amount that the arrows scroll
- ** the document, or whenever the document changes size. These values are first
- ** stored in the document's fileState structure. Once the new values are in
- ** place, call AdjustScrollBars to affect all related changes. */
-
- void GetContentOrigin(WindowPtr window, Point *contOrg);
- /* This function returns the origin of the content of the window. The value is
- ** gotten from the current value of the document scrollbars. If a scrollbar
- ** is missing, that related value is assumed to be 0. */
-
- void SetContentOrigin(WindowPtr window, short newh, short newv);
- /* This function allows you to change the value of the document scrollbars,
- ** and by doing this, the document is scrolled to reflect the change, and
- ** an update event is generated for the document scroll. */
-
- void GetContentRect(WindowPtr window, Rect *contRct);
- /* This function returns a rectangle that represents the content area of the
- ** window less the scrollbar area. */
-
- void SetDocSize(FileRecHndl frHndl, short hSize, short vSize);
- /* This function sets the document size to the new designated size. It also
- ** makes appropriate adjustments to the scrollbars to reflect the new size. */
-
- void DoImageDocument(FileRecHndl frHndl);
- /* This function is called whenever the content portion of a window needs to be
- ** updated or printed. It simply calls the procedure pointer stored in the field
- ** imageProc. The field imageProc is initialized to ImageDocument. If you wish
- ** an alternate imageProc, then you can replace the default in the function
- ** AppInitDocument, as the default is already established at this point. */
-
- void DoContentClick(WindowPtr window, EventRecord *event);
- /* This function is called whenever the content portion of a window is clicked in.
- ** It simply calls the procedure pointer stored in the field contentClickProc.
- ** The field contentClickProc is initialized to ContentClick. If you wish
- ** an alternate contentClickProc, then you can replace the default in the function
- ** AppInitDocument, as the default is already established at this point. */
-
- void DoContentKey(WindowPtr window, EventRecord *event);
- /* This function is called whenever a key event occurs that needs to be handled
- ** by the window. It simply calls the procedure pointer stored in the field
- ** contentKeyProc. The field contentClickProc is initialized to ContentClick. If
- ** you wish an alternate contentKeyProc, then you can replace the default in the function
- ** AppInitDocument, as the default is already established at this point. */
-
-
-
- /************** Window2.c **************/
-
- OSErr InitContent(FileRecHndl frHndl, WindowPtr window);
- /* This function is the default function for initializing the content area
- ** of a window. It is called by DoNewWindow unless you change the default
- ** content initialization procedure pointer. */
-
- void ImageDocument(FileRecHndl frHndl);
- /* This function is the default function for imaging the document into the
- ** window or into the printer port. It is called in response to update
- ** events, or in response to the user printing. You can change the imaging
- ** procedure pointer if you wish. This is only called as a default. */
-
- void ResizeContent(WindowPtr window, short oldh, short oldv);
- /* This function is the default function for resizing the document content.
- ** MacShell calls ResizeWindow, which handles resizing the document scrollbars.
- ** It then calls the content resizing procedure. This function is called by
- ** ResizeWindow unless you change the default content resizing
- ** procedure pointer. */
-
- void DrawFrame(FileRecHndl frHndl, WindowPtr window);
- /* This function is the default function for drawing the remainder of the
- ** frame. The MacShell document scrollbars and growIcon, if any, are already
- ** drawn. This function is called by DoDrawFrame unless you change the
- ** default frame drawing procedure pointer. */
-
- void CalcFrameRgn(FileRecHndl frHndl, WindowPtr window, RgnHandle rgn);
- /* This function is the default function for contributing to the frame calculation.
- ** MacShell document scrollbars and growIcon are contributed later automatically.
- ** Only if you have additional (or alternate) frame parts in your window should
- ** you add any code to this function. CalcFrameRgn is called by DoCalcFrameRgn
- ** unless you change the default frame region calculation procedure pointer.
- ** If you have no additional frame contribution, then you should simply return
- ** the region passed in unchanged. */
-
- void ContentClick(WindowPtr window, EventRecord *event);
- /* This function is the default function for handling click events for the window. */
-
- void ContentKey(WindowPtr window, EventRecord *event);
- /* This function is the default function for handling key events for the window. */
-
-